<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.db.conn"%>
<%@ page import="com.db.Pagination"%>
<%@ page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<jsp:include flush="true" page="${basePath}/admin/head.jsp"></jsp:include>
<style>
    .ms-panel {
        margin: 0;
        padding: 0;
        background: #fff;
        border-radius: 4px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    }
    
    .ms-panel-header {
        padding: 20px 24px;
        border-bottom: 1px solid #eee;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .ms-panel-header h6 {
        margin: 0;
        font-size: 18px;
        font-weight: 500;
        color: #333;
    }
    
    .ms-panel-body {
        padding: 24px;
    }
    
    .table-responsive {
        margin: 0;
    }
    
    .table {
        width: 100%;
        margin-bottom: 0;
        border-collapse: collapse;
    }
    
    .table th {
        background: #f8f9fa;
        color: #495057;
        font-weight: 500;
        padding: 12px 16px;
        text-align: left;
        border-bottom: 2px solid #dee2e6;
    }
    
    .table td {
        padding: 12px 16px;
        vertical-align: middle;
        border-bottom: 1px solid #dee2e6;
        color: #495057;
    }
    
    .table tr:hover {
        background-color: #f8f9fa;
    }
    
    .action-links {
        display: flex;
        gap: 8px;
    }
    
    .action-btn {
        padding: 6px 12px;
        border-radius: 4px;
        font-size: 13px;
        cursor: pointer;
        transition: all 0.3s ease;
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn-detail {
        background: #17a2b8;
        color: #fff;
        border: none;
    }
    
    .btn-detail:hover {
        background: #138496;
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .btn-delete {
        background: #dc3545;
        color: #fff;
        border: none;
    }
    
    .btn-delete:hover {
        background: #c82333;
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .comment-content {
        max-width: 300px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .pagination {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-top: 24px;
        gap: 8px;
    }
    
    .pagination a {
        padding: 8px 12px;
        border: 1px solid #dee2e6;
        border-radius: 4px;
        color: #007bff;
        text-decoration: none;
        transition: all 0.3s ease;
    }
    
    .pagination a:hover {
        background: #e9ecef;
        border-color: #dee2e6;
        color: #0056b3;
    }
    
    .pagination .active {
        background: #007bff;
        border-color: #007bff;
        color: #fff;
    }
    
    .pagination .disabled {
        color: #6c757d;
        pointer-events: none;
        background: #fff;
        border-color: #dee2e6;
    }
</style>
 </head>

 <body class="ms-body ms-aside-left-open ms-primary-theme ms-has-quickbar">
    <!-- Body Content Wrapper -->
    <div class="ms-content-wrapper">
        <div class="row">
            <div class="col-md-12">
                   <div class="ms-panel">
        <div class="ms-panel-header">
            <h6>管理小说评论信息</h6>
        </div>
        <div class="ms-panel-body">
            <div class="table-responsive">
                <table class="table">
                    <thead>
                        <tr>
                            <th>小说ID</th>
                            <th>小说名称</th>
                            <th>用户ID</th>
                            <th>评论内容</th>
                            <th>评论时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <%
                        int pageSize = 15;
                        int pageNow = 1;
                        int rowCount = 0;
                        int pageCount = 0;
                        
                        String s_pageNow = request.getParameter("pageNum");
                        if(s_pageNow != null) {
                            pageNow = Integer.parseInt(s_pageNow);
                        }
                        
                        String where = " 1=1 ";
                        conn cn = new conn();
                        
                        ResultSet rs = cn.query("select count(*) from comment a where " + where);
                        if(rs.next()) {
                            rowCount = rs.getInt(1);
                        }
                        
                        if(rowCount % pageSize == 0) {
                            pageCount = rowCount/pageSize;
                        } else {
                            pageCount = rowCount/pageSize + 1;
                        }
                        
                        rs = cn.query("select * from comment a left join books b on a.bid = b.bid where " + where + " order by id desc limit " + pageSize*(pageNow-1) + ", " + pageSize);
                        
                        while(rs.next()) {
                        %>
                        <tr>
                            <td><%=rs.getString("bid") %></td>
                            <td><%=rs.getString("bname") %></td>
                            <td><%=rs.getString("mid") %></td>
                            <td class="comment-content" title="<%=rs.getString("cmemo")%>">
                                <%=rs.getString("cmemo")!=null && rs.getString("cmemo").length()>20?rs.getString("cmemo").substring(0,20)+"……": rs.getString("cmemo")==null ?"":rs.getString("cmemo") %>
                            </td>
                            <td><%=rs.getString("ctime") %></td>
                            <td>
                                <div class="action-links">
                                    <a href="<%=path %>/admin/comment/comment_Detail.jsp?id=<%=rs.getString("id") %>" class="action-btn btn-detail">详细</a>
                                    <a href="<%=path %>/comment_Delete?id=<%=rs.getString("id") %>" class="action-btn btn-delete" onclick="return confirm('确定要删除这条评论吗？')">删除</a>
                                </div>
                            </td>
                        </tr>
                        <%} %>
                    </tbody>
                </table>
                
                <div class="pagination">
                    <%= Pagination.getPagination(pageNow,pageCount,rowCount,request.getRequestURI()) %>
                </div>
            </div>
        </div>
    </div>
            </div>
        </div>
    </div>
</body>
</html>







